﻿/*
 * Copyright 2014 Francois Karman
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using Quartz.WebManager.Model;
using System.Collections.Generic;

namespace Quartz.WebManager.Web.Models
{
    /// <summary>
    /// Represents a trigger.
    /// </summary>
    public class WebTrigger : Trigger
    {
        /// <summary>
        /// The supported misfire instructions.
        /// </summary>
        private readonly IDictionary<int, string> misfireInstructions;

        /// <summary>
        /// Initializes a new instance of the <see cref="WebTrigger"/> class.
        /// </summary>
        public WebTrigger()
            : this(null)
        { }

        public WebTrigger(Trigger trigger)
            : base(trigger)
        {
            this.misfireInstructions = new Dictionary<int, string>();
            this.MisfireInstructions.Add(Quartz.MisfireInstruction.SmartPolicy, "smart policy (fire once)");
            this.MisfireInstructions.Add(Quartz.MisfireInstruction.IgnoreMisfirePolicy, "ignore (fire all missed)");
            this.MisfireInstructions.Add(Quartz.MisfireInstruction.CronTrigger.DoNothing, "do nothing");
            this.MisfireInstructions.Add(Quartz.MisfireInstruction.CronTrigger.FireOnceNow, "fire once");
        }

        /// <summary>
        /// Gets or sets the job instance associated with this trigger.
        /// </summary>
        /// <remarks>
        /// This property is only used for display only.
        /// </remarks>
        public JobDetail JobDetail { get; set; }

        /// <summary>
        /// Gets the supported misfire instructions.
        /// </summary>
        public IDictionary<int, string> MisfireInstructions
        {
            get { return this.misfireInstructions; }
        }
    }
}